//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ComparePratt2PatternsByCATH.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String*          filenameOut             = NULL;
  int              position                = 0;
  TListE <String>* listPatternProfileFiles = new TListE <String> ();
  
  if (argc < 4) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./ComputePatternProfileSimilarity <Filename Out>";
    cout <<                                  " <Position in Pattern Profile>";
    cout <<                                  " <Pattern Profile File>";
    cout <<                                  " <Pattern Profile File>";
    cout <<                                  " [<Pattern Profile File> ...]";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameOut = new String(argv[1]);
    position    = atoi(argv[2]);
    
    for (int i = 3; i < argc; i++) 
      listPatternProfileFiles->Add(new String(argv[i]));
    
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "                Filename Out : " << argv[1] << endl;
    cout << " Position in Pattern Profile : " << argv[2] << endl;
    for (int i = 3; i < argc; i++) 
      cout << "        Pattern Profile File : " << argv[i] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    
  }
  
  ComparePratt2PatternsByCATH* comparePratt2PatternsByCATH = new ComparePratt2PatternsByCATH ();
  
  cout << "Preparing Files..." << endl;
  comparePratt2PatternsByCATH->FilenameOut(filenameOut);
  
  listPatternProfileFiles->SetInitial();
  while (listPatternProfileFiles->SetNext()) {
    Pratt2PatternsByCATH* newPratt2PatternsByCATH = new Pratt2PatternsByCATH ();
    newPratt2PatternsByCATH->Namefile(listPatternProfileFiles->GetCurrent());
    comparePratt2PatternsByCATH->ListPratt2PatternsByCATH()->Add(newPratt2PatternsByCATH);
  }

  cout << "Loading Patterns Prosite Files..." << endl;
  comparePratt2PatternsByCATH->LoadData();
  
  cout << "Writing results..." << endl;
  comparePratt2PatternsByCATH->GetPatternsSimilarity(position);
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (comparePratt2PatternsByCATH) delete comparePratt2PatternsByCATH;
  
  if (filenameOut)                 delete filenameOut;
  if (listPatternProfileFiles)     delete listPatternProfileFiles;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

